
#include "glut_interface.h"

glut_interface::glut_interface(void)
{
	LOG("hello glut_interface ......\n");

}

glut_interface::~glut_interface(void)
{

}

void glut_interface::MessageImmediate(int message_id, void *param)
{
	v3d_interface::MessageImmediate(message_id,param);
}

void glut_interface::Update(int message_id, void *param)
{
	v3d_interface::Update(message_id,param);
}

void glut_interface::Start()
{
	glutMainLoop();

}

void glut_interface::InitWindow()
{
	glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA | GLUT_MULTISAMPLE );
	glutInitWindowPosition( 100, 100 );
	glutInitWindowSize( 300, 300 );

	int argc = 1;
	char *argv[40] = {"test"};
	glutInit( &argc, argv );

	glutCreateWindow("simpleogl");

	glutReshapeFunc(glutResize);
	glutDisplayFunc(glutDisplay);

}

//glut functions
void glutResize(int width, int height)
{
	if(v3d_interface::I->v3dRenderer != NULL)
	{
		WINDOW_RESIZE_PARAM temp = {width,height};
		v3d_interface::I->v3dRenderer->MessageImmediate(MSG_I_WINDOW_RESIZE, &temp);
	}

}

void glutDisplay(void)
{
	if(v3d_interface::I->v3dRenderer != NULL)
		v3d_interface::I->v3dRenderer->Update(MSG_I_RENDERUPDATE, NULL);

    glutSwapBuffers();
}




